<template>
  <div class="goodsItem"
       @click="goPath">
    <div class="img-warp">
      <img :src="goodsInfo.g_picture"
           alt="">
    </div>
    <div class="desc">
      <div class="title text_row_1">
        {{goodsInfo.g_name}}
      </div>
      <div class="tag">
        <span>
          智能家居
        </span>
      </div>
      <div>
        <Progress :percent="progress"
                  :stroke-color="['#108ee9', '#87d068']"
                  text-inside
                  status="active"
                  :stroke-width="15" />
      </div>
      <div class="nowData">
        <div class="nowData-item">
          <p class="num">{{progress}}%</p>
          <p class="desc-text">已达</p>
        </div>
        <div class="nowData-item">
          <p class="num">￥{{goodsInfo.g_start_money}}</p>
          <p class="desc-text">已筹</p>
        </div>
        <div class="nowData-item">
          <p class="num">20天</p>
          <p class="desc-text">剩余时间</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    goodsInfo: {
      type: Object,
      default: {}
    }
  },
  computed: {
    progress() {
      const sNum = this.goodsInfo.g_start_money
      const eNum = this.goodsInfo.g_end_money
      const progress = parseInt((sNum / eNum) * 100)

      // return 100
      return isNaN(progress) ? 0 : progress >100 ? 100 : progress
    }
  },
  methods: {
    goPath() {

      if (this.goodsInfo.gid) {
        this.$router.push({
          path: '/front/detail',
          query: {
            gid: this.goodsInfo.gid
          }
        })
      }
    }
  }
}
</script>

<style scoped>
.goodsItem {
  width: calc(25% - 20px);
  height: 420px;
  /* border: 1px #ccc solid; */
  box-shadow: 0px 2px 20px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}
.img-warp {
  width: 100%;
  height: 220px;
  overflow: hidden;
  position: relative;
}
.img-warp img {
  width: 100%;
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: 1s;
  height: 100%;
}
.img-warp img:hover {
  width: 110%;
  height: 110%;
}
.desc {
  padding: 20px;
}
.title {
  color: #000;
  font-size: 16px;
  padding: 10px 0;
  font-weight: 600;
}
.nowData {
  display: flex;
  margin-top: 20px;
}
.nowData-item {
  flex: 1;
}
.num {
  font-size: 18px;
  color: #5e5e5e;
}
.desc-text {
  font-size: 12px;
  color: #b9adc5;
}
.tag span {
  padding: 0 10px;
  line-height: 30px;
  border: 1px solid #e9e9e9;
  border-radius: 15px;
  color: #a5a5a5;
  cursor: pointer;
}
.tag span:hover {
  color: #44b4ff;
  border-color: #44b4ff;
}
</style>